package cn.szzsi._admin;

import cn.szzsi.common.kit.CommonUtil;
import cn.szzsi.common.model.Reship;
import com.jfinal.kit.StrKit;

import java.util.List;

/**
 * 商户后台类 - 退货
 * Created by yuanzheg on 2016/10/13.
 */
public class ReshipController extends BaseAdminController<Reship> {
    private String shopId;
    // 列表
    public void list() {
        shopId=getAttr("shopId");
        findBusinessByPage(shopId,"mall_reship");
        render(CommonUtil.TEMPLATE_PATH+"/business/reshipmanage/reship_manage_list.html");
    }
    //ajax list
    public void ajaxlist(){
        shopId=getAttr("shopId");
        List<Reship> lr = Reship.dao.find("select * from mall_reship where uid = ? order by createDate desc",shopId);
        renderJson(lr);
    }

    // 查看
    public void view() {
        id = getPara("id", "");
        if (StrKit.notBlank(id)) {
            setAttr("reship", Reship.dao.findById(id));
            render(CommonUtil.TEMPLATE_PATH+"/business/reshipmanage/reship_manage_view.html");
        }
    }

    // 删除
    public void delete(){
        ids = getParaValues("ids");
        if(ids != null && ids.length > 0){
            for(String id : ids){
                if(Reship.dao.deleteById(id)){
                    ajaxJsonSuccessMessage("删除成功！");
                }else{
                    ajaxJsonErrorMessage("删除失败！");
                }
            }
        }
    }
}
